﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

namespace BLL.Admin
{
    public class DMKiNangHelper
    {
        public static void AddKiNang(string tenKiNang)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            tbl_DM_KiNang KiNang = new tbl_DM_KiNang();
            KiNang.TenKiNang = tenKiNang;
            db.tbl_DM_KiNangs.InsertOnSubmit(KiNang);
            db.SubmitChanges();
        }
        public static void UpdateKiNang(int Id, string tenKiNang)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            tbl_DM_KiNang KiNang = db.tbl_DM_KiNangs.FirstOrDefault(k => k.KiNangId == Id);
            KiNang.TenKiNang = tenKiNang;
            db.SubmitChanges();
        }

        public static IQueryable ListKiNangTheoNhomKiNang(int nhomKiNangId)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            var query = db.tbl_DM_KiNangs.Where(r => r.NhomKiNang == nhomKiNangId).Select(r => new
                                                                                                   {
                                                                                                       r.KiNangId,
                                                                                                       r.TenKiNang
                                                                                                   });
            return query;
        }
    }
}